{extend name="admin@public/base" /}
{block name="main-content"}
<link rel="stylesheet" type="text/css" href="__PUBLIC__/jQuery-Validation-Engine-2.6.2-ciaoca/css/validationEngine.jquery.css">
<script type="text/javascript" src="__PUBLIC__/jQuery-Validation-Engine-2.6.2-ciaoca/js/jquery.validationEngine-zh_CN.js"></script>
<script type="text/javascript" src="__PUBLIC__/jQuery-Validation-Engine-2.6.2-ciaoca/js/jquery.validationEngine.min.js"></script>
<div class="page-content">
    <!--主题-->
    <div class="page-header">
        <h1>
            您当前操作
            <small>
                <i class="ace-icon fa fa-angle-double-right"></i>
                新增资料权限
            </small>
        </h1>
    </div>
    <div class="row">
        <div class="col-xs-12">
            <form class="form-horizontal ajaxForm" name="" method="post" action="{:url('admin/AuthDoc/doAdd')}">
                <div class="form-group">
                    <label class="col-xs-3 control-label no-padding-right" for="form-field-1"> 用户组： </label>
                    <div class="col-sm-9">
                        <select id="group_id" name="group_id"  class="col-sm-5 selector validate[required]">
                            <option value="">请选择用户组</option>
                            {foreach name="group" item="v"}
                            <option value="{$v.id}">{$v.title}</option>
                            {/foreach}
                        </select>
                        <span class="lbl col-xs-12 col-sm-7"><span class="red">*</span>必选</span>
                    </div>
                </div>
                <div class="space-4"></div>

                <div class="form-group">
                <div class="table-header">
                    资料
                </div>
                <table id="dynamic-table" class="table table-striped-new table-bordered table-hover">
                    <thead>
                        <tr>
                            <td class="center all" width="10%">
                                <label class="pos-rel">
                                    <input type="checkbox" class="ace total" name="total" />
                                    <span class="lbl"></span>
                                </label>
                            </td>
                            <th>资料名称</th>

                            <td class="center" width="18%" style="font-weight: bold">权限</td>
                        </tr>
                    </thead>
                    <tbody>
                        {foreach name="doc" item="vv"}
                        <tr>
                            <td class="center">
                                <label class="pos-rel">
                                    <input type="checkbox" name="doc_id[]" value="{$vv.id}" class="ace big" />
                                    <span class="lbl"></span>
                                </label>
                            </td>

                            <td><a href="#">{$vv.name}</a></td>
                            <td class="center">
                                <label class="pos-rel">
                                    <input type="checkbox" name="auth{$vv.id}[]" value="1" class="ace small" la="{$vv.id}"/>
                                    <span class="lbl">读</span>
                                </label>
                                <label class="pos-rel">
                                    <input type="checkbox" name="auth{$vv.id}[]" value="2" class="ace small" la="{$vv.id}"/>
                                    <span class="lbl">写</span>
                                </label>
                                <label class="pos-rel">
                                    <input type="checkbox" name="auth{$vv.id}[]" value="3" class="ace small" la="{$vv.id}"/>
                                    <span class="lbl">删</span>
                                </label>
                            </td>
                        </tr>
                        {/foreach}
                    </tbody>
                </table>
                </div>
                <div class="clearfix form-actions">
                    <div class="col-md-offset-3 col-md-9">
                        <button class="btn btn-info" type="submit">
                            <i class="ace-icon fa fa-check bigger-110"></i>
                            保存
                        </button>
                        &nbsp; &nbsp; &nbsp;
                        <button class="btn" type="reset">
                            <i class="ace-icon fa fa-undo bigger-110"></i>
                            重置
                        </button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div><!-- /.page-content -->
{/block}
{block name="scripts"}
<script src="__PUBLIC__/assets/js/jquery.dataTables.min.js"></script>
<script src="__PUBLIC__/assets/js/jquery.dataTables.bootstrap.min.js"></script>
<script src="__PUBLIC__/assets/js/dataTables.buttons.min.js"></script>
<script src="__PUBLIC__/assets/js/buttons.flash.min.js"></script>
<script src="__PUBLIC__/assets/js/buttons.html5.min.js"></script>
<script src="__PUBLIC__/assets/js/buttons.print.min.js"></script>
<script src="__PUBLIC__/assets/js/buttons.colVis.min.js"></script>
<script src="__PUBLIC__/assets/js/dataTables.select.min.js"></script>
<script type="text/javascript">
    
    $('.form-horizontal').validationEngine('attach',{
        promptPosition: 'bottomLeft',
        addPromptClass: 'formError-white',
        showOneMessage: true
    });

        jQuery(function($) {
            //initiate dataTables plugin
            var myTable = $('#dynamic-table').DataTable( {"paging": false} );

            $('.total').click(function(){
                if (this.checked){
                        $("input:checkbox").each(function(){ 
                              $(this).prop("checked", true);  
                        });
                    } else {   
                        $("input:checkbox").each(function() {   
                              $(this).prop("checked", false);  
                        });
                    }
            });

            $('.small').click(function(){
                id = $(this).attr('la');
                if (this.checked){
                    $(this).parents('tr').find('.big').val(id).prop('checked',true);
                }
            });
        });

        
</script>
{/block}
